package it.fuesi.expired.api.controllers;

import it.fuesi.expired.api.controllers.base.ABaseController;
import it.fuesi.expired.model.base.ErrorModel;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ErrorController extends ABaseController {

	@ExceptionHandler(Exception.class)
	@ResponseBody
	public ErrorModel handleSQLException(HttpServletRequest request,
			Exception ex) {
		// logger.info("SQLException Occured:: URL="+request.getRequestURL());
		ex.printStackTrace();
		return ErrorModel.factory(ex);
	}

}
